{layout name="p/base"}
    <div class="row">
      <div class="col-lg-12">
        <h1>管理员管理 <small>管理员信息列表</small></h1>
        <ol class="breadcrumb">
          <li><a href="/manager/index"><i class="fa fa-dashboard"></i> 管理首页</a></li>
          <li><a href="admin-list.php"><i class="fa fa-dashboard"></i> 管理员信息列表</a></li>
          <li class="active"><i class="fa fa-table"></i> 添加管理员</li>
        </ol>
        <div class="alert alert-success alert-dismissable">
          <button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>
          这里可以添加、修改、删除管理员信息
        </div>
      </div>
    </div>
    <!-- /.row -->
    <div class="row">
      <div class="col-lg-12">
        <form class="form-horizontal" role="form" action="/manager/savemanager" method="post">
            <div class="modal-header">
            <h4 class="modal-title" id="myModalLabel">
               添加管理员（仅限超级管理员添加）
            </h4>
            </div>
            <div class="form-group">
              <label class="control-label col-sm-3">管理员账号<span id="phone_error" style="color: red;"></span></label>
              <div class="col-sm-9">
              <input class="form-control" type="text" name="branch_num" placeholder="请填写管理员手机号码">
              </div>
            </div>
            <div class="form-group">
              <label class="control-label col-sm-3">负责人姓名<span id="nameerror" style="color: red;"></span></label>
              <div class="col-sm-9">
              <input class="form-control" type="text" name="name" placeholder="请填写真实姓名">
              </div>
            </div>
            <div class="form-group">
              <label class="control-label col-sm-3">负责人邮箱<span id="emailerror" style="color: red;"></span></label>
              <div class="col-sm-9">
              <input class="form-control" type="text" name="email" placeholder="请填写正确邮箱">
              </div>
            </div>
            <div class="form-group">
              <label class="control-label col-sm-3">备注</label>
              <div class="col-sm-9">
                <input class="form-control" type="text" name="note" placeholder="请填写备注信息">
              </div>
            </div>
          </div>
          <div class="modal-footer">
            <a href="/manager/managerlist" type="button" class="btn btn-default" 
               data-dismiss="modal">返回
            </a>
            <button type="submit"  class="btn btn-primary">提交</button>
          </div>
        </form>
      </div>
    </div>
<script type="text/javascript">
          $(function(){
            //真实姓名
            $("input[name='name']").blur(function(){
              var name = $('input[name="name"]').val();
              //不能为空
              if(!$.trim(name)) {
              $("input[name='name']").css({border: "1px solid red"});
              $("#nameerror").html("必填");
              return false;
              }else{
                $("input[name='name']").css({border: "1px solid green"});
              $("#nameerror").html("");
              }
            })
            
            //邮箱
            $("input[name='email']").blur(function(){
              var email = $('input[name="email"]').val();
              //不能为空
              if(!$.trim(email)) {
              $("input[name='email']").css({border: "1px solid red"});
              $("#emailerror").html("必填");
              return false;
              }else{
                $.get('/manager/checkemail?email='+$("input[name='email']").val(),function(data) {
                $("input[name='email']").css({border: "1px solid green"});
                $("#emailerror").html("");
                if (data===0) {
                  $("input[name='email']").css({border: "1px solid red"});
                  $("#emailerror").html("格式不正确");
                }
              });
              }
            })
            //手机格式
            $("input[name='branch_num']").blur(function(){
              var branch_num = $('input[name="branch_num"]').val();
              //不能为空
              if(!$.trim(branch_num)) {
              $("input[name='branch_num']").css({border: "1px solid red"});
              $("#phone_error").html("必填");
              return false;
              }
              //手机号格式是否满足
              if((/^1[3|4|5|7|8]\d{9}$/.test(branch_num)) || (/(^[a-zA-Z0-9_-]+@[a-zA-Z0-9_-]+\.[a-zA-Z0-9_-]+$)|(^$)/.test(branch_num))){
              $("input[name='branch_num']").css({border: "1px solid green"});
              $("#phone_error").html("");
              }else {
              $("input[name='branch_num']").css({border: "1px solid red"});
              $("#phone_error").html("格式不正确");
              return false;
              }
            })
          })
</script>